import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  server: {
    port: 9090,
    host: true,
    open: true,
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy
      '/dev-api': {
        target: 'http://localhost:7000',
        // target: 'https://api.wzs.pub/mock/13',
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-api/, '')
      },
      '/profile': {
        target: 'http://localhost:7000',
        changeOrigin: true,
      },
      '/upload': {
        target: 'http://localhost:7000',
        changeOrigin: true,
      }, '/chat': {
        target: 'ws://localhost:7000',
        // target: 'https://api.wzs.pub/mock/13',
        changeOrigin: true
      }

    }
  },
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
